﻿using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Erp.Migrations
{
    /// <inheritdoc />
    public partial class modify_table_OutboundRec_2 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_OutboundDetls_MatlInfo_MatlInfoId",
                table: "OutboundDetls");

            migrationBuilder.DropForeignKey(
                name: "FK_OutboundDetls_OutboundRecs_OutboundRecId",
                table: "OutboundDetls");

            migrationBuilder.DropForeignKey(
                name: "FK_OutboundRecs_MatlWhse_MatlWhseId",
                table: "OutboundRecs");

            migrationBuilder.DropPrimaryKey(
                name: "PK_OutboundRecs",
                table: "OutboundRecs");

            migrationBuilder.DropPrimaryKey(
                name: "PK_OutboundDetls",
                table: "OutboundDetls");

            migrationBuilder.RenameTable(
                name: "OutboundRecs",
                newName: "OutboundRec",
                newSchema: "Erp");

            migrationBuilder.RenameTable(
                name: "OutboundDetls",
                newName: "OutboundDetl",
                newSchema: "Erp");

            migrationBuilder.RenameIndex(
                name: "IX_OutboundRecs_MatlWhseId",
                schema: "Erp",
                table: "OutboundRec",
                newName: "IX_OutboundRec_MatlWhseId");

            migrationBuilder.RenameIndex(
                name: "IX_OutboundDetls_OutboundRecId",
                schema: "Erp",
                table: "OutboundDetl",
                newName: "IX_OutboundDetl_OutboundRecId");

            migrationBuilder.RenameIndex(
                name: "IX_OutboundDetls_MatlInfoId",
                schema: "Erp",
                table: "OutboundDetl",
                newName: "IX_OutboundDetl_MatlInfoId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_OutboundRec",
                schema: "Erp",
                table: "OutboundRec",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_OutboundDetl",
                schema: "Erp",
                table: "OutboundDetl",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_OutboundDetl_MatlInfo_MatlInfoId",
                schema: "Erp",
                table: "OutboundDetl",
                column: "MatlInfoId",
                principalSchema: "Erp",
                principalTable: "MatlInfo",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_OutboundDetl_OutboundRec_OutboundRecId",
                schema: "Erp",
                table: "OutboundDetl",
                column: "OutboundRecId",
                principalSchema: "Erp",
                principalTable: "OutboundRec",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_OutboundRec_MatlWhse_MatlWhseId",
                schema: "Erp",
                table: "OutboundRec",
                column: "MatlWhseId",
                principalSchema: "Erp",
                principalTable: "MatlWhse",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_OutboundDetl_MatlInfo_MatlInfoId",
                schema: "Erp",
                table: "OutboundDetl");

            migrationBuilder.DropForeignKey(
                name: "FK_OutboundDetl_OutboundRec_OutboundRecId",
                schema: "Erp",
                table: "OutboundDetl");

            migrationBuilder.DropForeignKey(
                name: "FK_OutboundRec_MatlWhse_MatlWhseId",
                schema: "Erp",
                table: "OutboundRec");

            migrationBuilder.DropPrimaryKey(
                name: "PK_OutboundRec",
                schema: "Erp",
                table: "OutboundRec");

            migrationBuilder.DropPrimaryKey(
                name: "PK_OutboundDetl",
                schema: "Erp",
                table: "OutboundDetl");

            migrationBuilder.RenameTable(
                name: "OutboundRec",
                schema: "Erp",
                newName: "OutboundRecs");

            migrationBuilder.RenameTable(
                name: "OutboundDetl",
                schema: "Erp",
                newName: "OutboundDetls");

            migrationBuilder.RenameIndex(
                name: "IX_OutboundRec_MatlWhseId",
                table: "OutboundRecs",
                newName: "IX_OutboundRecs_MatlWhseId");

            migrationBuilder.RenameIndex(
                name: "IX_OutboundDetl_OutboundRecId",
                table: "OutboundDetls",
                newName: "IX_OutboundDetls_OutboundRecId");

            migrationBuilder.RenameIndex(
                name: "IX_OutboundDetl_MatlInfoId",
                table: "OutboundDetls",
                newName: "IX_OutboundDetls_MatlInfoId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_OutboundRecs",
                table: "OutboundRecs",
                column: "Id");

            migrationBuilder.AddPrimaryKey(
                name: "PK_OutboundDetls",
                table: "OutboundDetls",
                column: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_OutboundDetls_MatlInfo_MatlInfoId",
                table: "OutboundDetls",
                column: "MatlInfoId",
                principalSchema: "Erp",
                principalTable: "MatlInfo",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_OutboundDetls_OutboundRecs_OutboundRecId",
                table: "OutboundDetls",
                column: "OutboundRecId",
                principalTable: "OutboundRecs",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_OutboundRecs_MatlWhse_MatlWhseId",
                table: "OutboundRecs",
                column: "MatlWhseId",
                principalSchema: "Erp",
                principalTable: "MatlWhse",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
